<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf"%>
<!DOCTYPE html>
<html lang="en">
<head>
	<title>绑定店铺列表</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link type="text/css" rel="stylesheet" href="${staticPath}/layui/css/layui.css">
	<link type="text/css" rel="stylesheet" href="${staticPath}/layui/modules/css/common.css">
</head>
<body style="padding:0 30px;">
<blockquote class="layui-elem-quote" style=" border-left: 0px solid #FFFFFF; background-color: #FFFFFF">
	<img src="${staticPath}/layui/modules/images/login/team.png" /> 商户个人中心
</blockquote>
<blockquote class="layui-elem-quote">
	绑定店铺
</blockquote>
<form class="layui-form">
	<div>
		<div class="box-submit">
			<label>
				<p><span>*</span>客户：</p>
				<input type="hidden" name="id" id="id" value="${data.id }">
				<input type="hidden" name="userName" id="userName" value="${data.userName }" >
				<%--<input type="text" class="layui-input" required  lay-verify="required" name="userName" value="${data.userName }"/>--%>
				<select lay-ignore style="width:427px;margin-top: 35px;" name="userId" class="layui-input" lay-verify="required" id="userId">
					<option value=""></option>
					<c:forEach items="${users}" var="user">
						<option value="${user.id}"
								<c:if test="${user.id==data.userId}" >
									selected = "selected"
								</c:if>
						>${user.name}</option>
					</c:forEach>
				</select>
			</label>
		</div>
		<div class="box-submit">
			<label>
				<p><span>*</span>店铺名称：</p>
				<input type="text" class="layui-input" required  lay-verify="required" name="shopName" value="${data.shopName }"/>
			</label>
		</div>
		<div class="button">
			<button class="layui-btn layui-btn-danger" lay-submit="" lay-filter="submit">提交绑定</button>
		</div>
	</div>
</form>
<script src="${staticPath}/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['jquery','layer','form'], function(){
        var $ = layui.jquery,form = layui.form,layer = layui.layer;
        //监听提交
        form.on('submit(submit)', function(data){
            layer.load(1);
            $.ajax({
                url: '${adminPath}/client/shop/create',
                data:data.field,
                type: "POST",
                dataType: "JSON",
                success: function(result){
                    layer.closeAll('loading');
                    if(result.ret==0){
                        layer.alert(result.msg, {icon: 0, title:'提示',end: function(){
                                window.location.href="${adminPath}/client/shop";
                            }});
                    }else{
                        layer.alert(result.msg, {icon: 0, title:'警告'});
                    }
                },
                error: function () {
                    layer.closeAll('loading');
                    layer.msg("未知错误，请联系管理员！",{icon: 2});
                }
            });
            return false;
        });

        $("#userId").bind({
			change:function(){
			    $("#userName").val($(this).find("option:selected").text());
			}
		});
    });
</script>
</body>
</html>